#ifndef _DICOM_HANDLER_HANDLER_COMMON_H
#define _DICOM_HANDLER_HANDLER_COMMON_H

#include <gwbase/base/util.h>
#include "dicom/http_handler.h"
#include "dicom/session.h"
#include "dicom/hippa_log.h"
#include "dicom/gateway.h"
#include <onion/response.h>
#include <onion/request.h>

namespace dicom {

/*
extern Status CheckToken(mg_connection* conn, CredentialPtr* cred);

extern void SendSimpleResponse(mg_connection* conn,
                               int result_code,
                               const std::string& msg);


extern void SendJsonResult(mg_connection* conn, Json::Value& v);
*/

extern Status CheckToken(onion_request* conn, CredentialPtr* cred,
                         std::string* token = NULL);
extern void SendSimpleResponse(onion_response* resp, int result_code,
                               const std::string& msg);
extern void SendJsonResult(onion_response* resp, int http_code, Json::Value& v);

// return empty if not found
extern std::string GetQueryString(onion_request* req, const char* name);

extern int64_t GetQueryStringInt64(onion_request* req, const char* name,
                                   int64_t default_value);

// return "/", "/abc", and so no
extern std::string GetReqPath(onion_request* req);

extern int GetReqMethod(onion_request* req);
extern std::string GetReqMethodStr(onion_request* req);
}

#endif  // _DICOM_HANDLER_HANDLER_COMMON_H
